package com.bckj.fastboot.iot.parse.service.impl;

import com.bckj.fastboot.iot.common.dto.request.IotStatusDataRequest;
import com.bckj.fastboot.iot.common.repository.IotLiveDataRepository;
import com.bckj.fastboot.iot.common.repository.IotStatusDataRepository;
import com.bckj.fastboot.iot.parse.service.IotStatusDataService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * IotStatusDataHandler
 *
 * @author wfc
 **/
@Service
public class IotStatusDataServiceImpl implements IotStatusDataService {

    @Resource
    private IotStatusDataRepository iotStatusDataRepository;
    @Resource
    private IotLiveDataRepository iotLiveDataRepository;

    public void handle(IotStatusDataRequest request) {
        // 保存历史数据
        iotStatusDataRepository.save(request);
        // 更新最新数据
        iotLiveDataRepository.save(request.getDevCode(), request.getDataMap());
    }
}
